<template>
  <div>
    <!-- 1. 准备绘制echarts图表的div -->
    <div ref="box" class="box">1111</div>
  </div>
</template>

<script>
// 2. 导入echarts方法
// 导入所有图表
// import * as echarts from 'echarts'
// 按需
// import * as echarts from 'echarts/core'
// import { TooltipComponent } from 'echarts/components'
// import { RadarChart } from 'echarts/charts'
// import { CanvasRenderer } from 'echarts/renderers'

// echarts.use([TooltipComponent, RadarChart, CanvasRenderer])
export default {
  mounted () {
    this.initChart()
  },
  methods: {
    initChart () {
      // 基于准备好的dom，初始化echarts实例
      const myChart = this.echarts.init(this.$refs.box)
      // 绘制图表=> 传入不同图表的配置对象options:{}
      // 动态切换核心改option里的data=》重新调用myChart.setOption方法
      const option = {
        // 数据项提示
        tooltip: {},
        radar: {
          // shape: 'circle',
          axisName: {
            // textStyle: {
            color: '#fff',
            backgroundColor: '#999',
            borderRadius: 3,
            padding: [3, 5]
            // }
          },
          // 数据项指标
          indicator: [
            { name: '工作效率', max: 100 },
            { name: '考勤', max: 100 },
            { name: '积极性', max: 100 },
            { name: '帮助同事', max: 100 },
            { name: '自主学习', max: 100 },
            { name: '正确率', max: 100 }
          ]
        },
        // 指定图表的数据
        series: [
          {
            type: 'radar',
            data: [
              {
                value: [10, 1, 100, 5, 100, 0],
                name: '张三'
              },
              {
                value: [100, 100, 50, 50, 50, 10],
                name: '李四'
              }
            ]
          }
        ]
      }
      myChart.setOption(option)
    }
  }
}
</script>

<style lang="scss" scoped>
.box {
  width: 100%;
  height: 400px;
}
</style>
